//
//  CYAddressBookTool.h
//  CreditAddressBook
//
//  Created by Lee on 15/9/16.
//  Copyright (c) 2015年 Lee. All rights reserved.
//  调用系统通讯录封装

#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
#if IS_IOS9
#import <ContactsUI/ContactsUI.h>
#import <Contacts/Contacts.h>
#endif

@class RHPerson;
@class CNContact;
@class CYContacts;

typedef void(^CYABBloc)(RHPerson *person);
typedef void(^CYCNBlock)(CNContact *contact);
typedef void(^CYBlock)(id obj);

@interface CYAddressBookTool : NSObject

/**
 *  调用系统联系人选择界面 iOS9以下
 *
 *  @param controller
 *  @param isEdit
 *  @param completion
 */
+ (void)ABAddressBookUIPickerWithController:(UIViewController *)controller edit:(BOOL)isEdit completion:(CYABBloc)completion;

/**
 *  编辑已有号码 iOS9以下
 *
 *  @param controller
 *  @param person
 *  @param isEdit
 *  @param completion
 */
+ (void)ABUnknownPersonWithController:(UIViewController *)controller person:(RHPerson *)person edit:(BOOL)isEdit completion:(CYABBloc)completion;

/**
 *  添加新号码 iOS9以下
 *
 *  @param controller
 *  @param person
 *  @param completion
 */
+ (void)ABNewPersonWithController:(UIViewController *)controller person:(RHPerson *)person completion:(CYABBloc)completion;

/**
 *  创建一个RHPerson
 *
 *  @param phones 电话号码
 *  @param name 姓名
 *
 *  @return
 */
+ (RHPerson *)newRHPersonWithName:(NSString *)name phones:(NSArray *)phones;

/**
 *  调用系统联系人选择界面 ios9以上
 *
 *  @param controller <#controller description#>
 *  @param isEdit     <#isEdit description#>
 *  @param completion <#completion description#>
 */
+ (void)CNAddressBookUIPickerWithController:(UIViewController *)controller edit:(BOOL)isEdit completion:(CYCNBlock)completion;

/**
 *  添加新号码 ios9以上
 *
 *  @param controller <#controller description#>
 *  @param person     <#person description#>
 *  @param completion <#completion description#>
 */
+ (void)CNNewPersonWithController:(UIViewController *)controller person:(CNContact *)person completion:(CYCNBlock)completion;

/**
 *  调用系统联系人选择界面,根据系统版本辨别
 *
 *  @param controller <#controller description#>
 *  @param isEdit     <#isEdit description#>
 *  @param completion <#completion description#>
 */
+ (void)addressBookUIPickerWithController:(UIViewController *)controller edit:(BOOL)isEdit completion:(CYBlock)completion;

/**
 *  添加新号码,根据系统版本辨别
 *
 *  @param controller <#controller description#>
 *  @param person     <#person description#>
 *  @param completion <#completion description#>
 */
+ (void)newPersonWithController:(UIViewController *)controller person:(CYContacts *)person completion:(CYBlock)completion;

/**
 *  系统联系人编辑界面
 *
 *  @param controller <#controller description#>
 *  @param person     <#person description#>
 *  @param completion <#completion description#>
 */
+ (void)ABPersonViewController:(UIViewController *)controller person:(RHPerson *)person completion:(CYBlock)completion;
/**
 *  系统联系人编辑界面
 *
 *  @param controller
 *  @param person
 *  @param completion 
 */
- (void)ABPersonViewController:(UIViewController *)controller person:(RHPerson *)person completion:(CYBlock)completion;
@end
